package org.fhm.zdte.common.constant;

import org.fhm.substrate.annotation.BeanInitial;
import org.fhm.substrate.annotation.Component;
import org.fhm.substrate.annotation.Setup;
import org.fhm.zdte.common.config.ProtocolConfiguration;

/**
 * Constants related to data transfer.
 *
 * @author 谭波
 * @since 2024/4/3
 */
@Component
public class DataTransform {

    public static final String DATA = "DATA";
    public static final String PROXY_PACKET_SEPARATOR = " \t ";
    public static final String PROXY_PACKET_HEAD_SEPARATOR = "\n";
    public static final String FILE_KEY = "file";
    public static final String FILE_NAME_KEY = "fileName";
    public static final int FILE_SIZE_MAX = 1024 * 1024 * 1024;
    public static int NUMBER_OF_FLOWS;
    @Setup
    private ProtocolConfiguration protocolConfiguration;

    @BeanInitial
    private void beanInitial() {
        int netRate = protocolConfiguration.getNetRate();
        int packetLength = protocolConfiguration.getPacketLength();
        if (netRate != 0)
            NUMBER_OF_FLOWS = (netRate * 1024 * 1024) / 8 / packetLength;
    }

}
